package com.sm.auth.controller;

import com.sm.common.constants.HttpStatus;
import com.sm.common.response.Result;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.InternalAuthenticationServiceException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(InternalAuthenticationServiceException.class)
    public Result handleInternalAuthenticationServiceException() {
        return new Result(HttpStatus.BAD_USERNAME,"用户名不存在！");
    }
    @ExceptionHandler(BadCredentialsException.class)
    public Result handleBadCredentialsException() {
        return new Result(HttpStatus.BAD_PASSWORD,"密码输入错误！");
    }
    @ExceptionHandler(Exception.class)
    public Result handleException() {
        return Result.error("其他类型的异常！！！");
    }
}
